package com.kuang.utils;

import java.util.HashMap;

/**
 * @ClassName : R
 * @Description : 返回类封装
 * @Author : li wanqiu
 * @Date: 2020-11-10 16:21
 */
public class R extends HashMap<String,Object> {

    public R() {
        put("CODE",0);
        put("MSG","成功");
    }
    public static R oK(Integer code, String msg) {
        R r = new R();
        r.put("CODE",code);
        r.put("MSG",msg);
        return r;
    }
    public static R oK(Integer code, String msg,Object DATA){
        R r = new R();
        r.put("CODE",code);
        r.put("MSG",msg);
        r.put("DATA",DATA);
        return r;
    }
    public static R error(){
        return error(1,"失败");
    }
    public static R oK(String msg){
        return oK(500,msg);
    }
    public static R error(Integer code, String msg){
        R r = new R();
        r.put("CODE",code);
        r.put("MSG",msg);
        return r;
    }
    public static R error(Integer code, String msg,Object data){
        R r = new R();
        r.put("CODE",code);
        r.put("MSG",msg);
        r.put("DATA",data);
        return r;
    }

}
